<?php
/******************************
 * EQdkp
 * Copyright 2002-2003
 * Licensed under the GNU GPL.  See COPYING for full terms.
 * ------------------
 * page_header.php
 * begin: Wed December 18 2002
 *
 * $Id: page_header.php 541 2008-05-20 06:56:16Z rspeicher $
 *
 ******************************/

// Define a variable so we know the header's been included
define('HEADER_INC', true);

// Use gzip if available
if ( $eqdkp->config['enable_gzip'] == '1' )
{
    if ( (extension_loaded('zlib')) && (!headers_sent()) )
    {
        ob_start('ob_gzhandler');
    }
}

$SID = ( isset($SID) ) ? $SID : '?' . URI_SESSION . '=';

// Switch login/logout link
if ( $user->data['user_id'] != ANONYMOUS )
{
    $u_login_logout = $eqdkp_root_path . 'login.php'.$SID.'&amp;logout=true';
    $l_login_logout = $user->lang['logout'] . ' [ ' . $user->data['username'] . ' ]';
}
else
{
    $u_login_logout = $eqdkp_root_path . 'login.php'.$SID;
    $l_login_logout = $user->lang['login'];
}

// Send the HTTP headers
$now = gmdate('D, d M Y H:i:s', time()) . ' GMT';
header('Expires: ' . $now); // rfc2616 - Section 14.21
header('Last-Modified: ' . $now);
header('Cache-Control: no-store, no-cache, must-revalidate, pre-check=0, post-check=0, max-age=0'); // HTTP/1.1
header('Pragma: no-cache'); // HTTP/1.0
header('Content-Type: text/html; charset=' . $user->lang['ENCODING']);

// Assign global template variables
$tpl->assign_vars(array(
    'ENCODING' => $user->lang['ENCODING'],
    'XML_LANG' => $user->lang['XML_LANG'],
    'PAGE_TITLE' => $page_title,
    'MAIN_TITLE' => $eqdkp->config['main_title'],
    'SUB_TITLE' => $eqdkp->config['sub_title'],
    'EQDKP_ROOT_PATH' => $eqdkp_root_path,
    'TEMPLATE_PATH' => $eqdkp_root_path . 'templates/' . $user->style['template_path'])
);

$tpl->assign_vars(array(
    'S_NORMAL_HEADER' => false,
    'S_ADMIN' => $user->check_auth('a_', false),
    
    'URI_ADJUSTMENT' => URI_ADJUSTMENT,
    'URI_EVENT' => URI_EVENT,
    'URI_ITEM' => URI_ITEM,
    'URI_LOG' => URI_LOG,
    'URI_NAME' => URI_NAME,
    'URI_NEWS' => URI_NEWS,
    'URI_ORDER' => URI_ORDER,
    'URI_PAGE' => URI_PAGE,
    'URI_RAID' => URI_RAID,
    'URI_SESSION' => URI_SESSION,

    'SID' => $SID,

    // Theme Settings
    'T_FONTFACE1' => $user->style['fontface1'],
    'T_FONTFACE2' => $user->style['fontface2'],
    'T_FONTFACE3' => $user->style['fontface3'],
    'T_FONTSIZE1' => $user->style['fontsize1'],
    'T_FONTSIZE2' => $user->style['fontsize2'],
    'T_FONTSIZE3' => $user->style['fontsize3'],
    'T_FONTCOLOR1' => $user->style['fontcolor1'],
    'T_FONTCOLOR2' => $user->style['fontcolor2'],
    'T_FONTCOLOR3' => $user->style['fontcolor3'],
    'T_FONTCOLOR_NEG' => $user->style['fontcolor_neg'],
    'T_FONTCOLOR_POS' => $user->style['fontcolor_pos'],
    'T_BODY_BACKGROUND' => $user->style['body_background'],
    'T_TABLE_BORDER_WIDTH' => $user->style['table_border_width'],
    'T_TABLE_BORDER_COLOR' => $user->style['table_border_color'],
    'T_TABLE_BORDER_STYLE' => $user->style['table_border_style'],
    'T_BODY_LINK' => $user->style['body_link'],
    'T_BODY_LINK_STYLE' => $user->style['body_link_style'],
    'T_BODY_HLINK' => $user->style['body_hlink'],
    'T_BODY_HLINK_STYLE' => $user->style['body_hlink_style'],
    'T_HEADER_LINK' => $user->style['header_link'],
    'T_HEADER_LINK_STYLE' => $user->style['header_link_style'],
    'T_HEADER_HLINK' => $user->style['header_hlink'],
    'T_HEADER_HLINK_STYLE' => $user->style['header_hlink_style'],
    'T_TH_COLOR1' => $user->style['th_color1'],
    'T_TR_COLOR1' => $user->style['tr_color1'],
    'T_TR_COLOR2' => $user->style['tr_color2'],
    'T_INPUT_BACKGROUND' => $user->style['input_color'],
    'T_INPUT_BORDER_WIDTH' => $user->style['input_border_width'],
    'T_INPUT_BORDER_COLOR' => $user->style['input_border_color'],
    'T_INPUT_BORDER_STYLE' => $user->style['input_border_style'])
);

if ( !$gen_simple_header )
{
    $main_menu1  = '';
    $main_menu1 .= '<a href="' . $eqdkp_root_path . 'index.php'.$SID . '" class="copy">' . $user->lang['menu_news'] . '</a>';
    $main_menu1 .= ' | <a href="' . $eqdkp_root_path . 'listmembers.php'.$SID . '" class="copy">' . $user->lang['menu_standings'] . '</a>';
    $main_menu1 .= ' | <a href="' . $eqdkp_root_path . 'listraids.php'.$SID . '" class="copy">' . $user->lang['menu_raids'] . '</a>';
    $main_menu1 .= ' | <a href="' . $eqdkp_root_path . 'listevents.php'.$SID . '" class="copy">' . $user->lang['menu_events'] . '</a>';
    $main_menu1 .= ' | <a href="' . $eqdkp_root_path . 'listitems.php'.$SID . '" class="copy">' . $user->lang['menu_itemval'] . '</a>';
    $main_menu1 .= ' | <a href="' . $eqdkp_root_path . 'listitems.php'.$SID.'&amp;' . URI_PAGE . '=history" class="copy">' . $user->lang['menu_itemhist'] . '</a>';
    $main_menu1 .= ' | <a href="' . $eqdkp_root_path . 'summary.php'.$SID . '" class="copy">' . $user->lang['menu_summary'] . '</a>';
    $main_menu1 .= ' | <a href="' . $eqdkp_root_path . 'stats.php'.$SID . '" class="copy">' . $user->lang['menu_stats'] . '</a>';
    do_hook('main_menu1', $main_menu1);
    
    $main_menu2  = '';
    $main_menu2 .= '<a href="' . $eqdkp_root_path . ( ($user->data['user_id'] != ANONYMOUS) ? 'settings.php'.$SID . '" class="copy">' . $user->lang['menu_settings']
                   : 'register.php'.$SID . '" class="copy">' . $user->lang['menu_register']) . '</a>';
    $main_menu2 .= ' | ' . ( ($user->check_auth('a_', false) ) ? '<a href="' . $eqdkp_root_path . 'admin/index.php'.$SID . '" target="_top" class="copy">' . $user->lang['menu_admin_panel'] . '</a> | ' : '');
    $main_menu2 .= '<a href="' . $u_login_logout . '" target="_top" class="copy">' . $l_login_logout . '</a>';
    do_hook('main_menu2', $main_menu2);
    
    $tpl->assign_vars(array(
        'LOGO_PATH' => $user->style['logo_path'],
        
        'S_NORMAL_HEADER' => true,
        'S_LOGGED_IN' => ( $user->data['user_id'] != ANONYMOUS ) ? true : false,

        // Menu
        'MAIN_MENU1' => $main_menu1,
        'MAIN_MENU2' => $main_menu2)
      );
}
?>